#![cfg_attr(
all(not(debug_assertions), target_os = "windows"),
windows_subsystem = "windows"
)]

use app::action::ActionType;
use app::cmd_result::CmdResult;

#[tauri::command]
async fn command(action: ActionType, json: String) -> CmdResult {
    match app::action::execute(action, json).await {
        Ok(o) => o,
        Err(e) => CmdResult { success: false, data: String::new(), message: e.to_string() }
    }
}

fn main() {
    tauri::Builder::default()
        .invoke_handler(tauri::generate_handler![command])
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}

// use serde::{Serialize, Deserialize};
//
// #[tokio::main]
// async fn main() {
//     #[derive(Deserialize, Serialize)]
//     struct P { id: u16, db: String, tb: String }
//     use app::db::real_time_db::RealTimeDatabase as db;
//
//     let p = P{ id: 1, db: "HX_RTDB".to_string(), tb: "HX_SQL".to_string() };
//     let json = serde_json::to_string(&p).unwrap();
//     let x = db::json(json).generate_sdk_tags().await.unwrap();
//     println!("{:?}", x)
// }